PLUGIN.Name = "Physics Gun Sounds"
PLUGIN.DefaultOn = false
PLUGIN.Description = "Adds sounds to Physics Gun."

function PLUGIN:LoadParameters()
	--self:AddParameter("sound_label", { Type = "label", Text = "Sound to play :" } )
	--self:AddParameter("sound", { Type = "textentry", Defaults = "buttons/blip1.wav" } )
	
end

function PLUGIN:Load()
	self.LastPick = 0
	self.LastDrop = 0
end

function PLUGIN:_MakeMySound()
	if not LocalPlayer() then return end
	
	self.MySound = CreateSound(LocalPlayer(), "Weapon_MegaPhysCannon.HoldSound")
end

function PLUGIN.HOOK:PhysgunPickup( ply, ent )
	if ply ~= LocalPlayer() then return end
	
	if not self.MySound then self:_MakeMySound() end
	
	self.MySound:Play()
	
	if CurTime() > (self.LastPick + 0.1) then
		self.LastPick = CurTime()
		LocalPlayer():EmitSound("Weapon_PhysCannon.Pickup")
	end
	
end

function PLUGIN.HOOK:PhysgunDrop( ply, ent )
	if ply ~= LocalPlayer() then return end
	
	if self.MySound then self.MySound:Stop() end
	
	if CurTime() > (self.LastDrop + 0.1) then
		self.LastDrop = CurTime()
		LocalPlayer():EmitSound("Weapon_PhysCannon.Drop")		
	end

end

function PLUGIN:Unload()
	if self.MySound then self.MySound:Stop() end
end
